package com.tgjorgoski.spellcheck.highlight;

import java.util.*;

import javax.swing.text.Document;
import javax.swing.text.Highlighter.HighlightPainter;

/**
 * 
 * 
 * @author Tanasije Gjorgoski <tanasije.gjorgoski@xyleme.com>
 */
public abstract class NodesHighlighter {

    private List listeners = new Vector(); 
    
    public void addHighlightChangeListener(HighlightParametersChangeListener listener) {
        listeners.add(listener);
    }
    public void removeHighlightChangeListener(HighlightParametersChangeListener listener) {
        listeners.remove(listener);
    }
    protected void fireHighlightChangeListeners() {
        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
            HighlightParametersChangeListener listener = (HighlightParametersChangeListener) iter.next();
            listener.highlightParametersChange(this);
        }
    }
	/**
	 * Returned HighlightPainter must be same one for same instance of this class, 
	 * because the other classes use the comparation of references (==)
	 * to find and remove the highlightPainters later
	 * @return
	 */
	abstract HighlightPainter getHighlighterPainter();
	abstract NodeSectionsIterator getNodeSectionsIterator(Document doc);

}
